package org.flexthinker.binding.bean
{
    import mx.events.PropertyChangeEvent;

    /**
     * Used for tests purposes
     */
    public class BindingListenerCounter implements BindingListener
    {
        public var boundCounter:int;
        public var unboundCounter:int;
        public var sourceChangedCounter:int;
        public var syncedCounter:int;
        public var syncFailedCounter:int;
        public var targetChangedCounter:int;

        public var counter:int;

        public var lastSyncFailure:SyncFailure;

        public function BindingListenerCounter()
        {
        }


        public function bindingBecameBound(binding:Binding):void
        {
            boundCounter++;
            counter++;
        }

        public function bindingBecameUnbound(binding:Binding):void
        {
            unboundCounter++;
            counter++;
        }

        public function sourceChanged(binding:Binding, event:PropertyChangeEvent):void
        {
            sourceChangedCounter++;
            counter++;
        }

        public function synced(binding:Binding):void
        {
            syncedCounter++;
            counter++;
        }


        public function syncFailed(binding:Binding, failure:SyncFailure):void
        {
            syncFailedCounter++;
            counter++;
            lastSyncFailure = failure;
        }

        public function targetChanged(binding:Binding, event:PropertyChangeEvent):void
        {
            targetChangedCounter++;
            counter++;
        }
    }
}
